home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / Sleep Deprivation 1.0 Source / Sleep Deprivation ƒ / sd wipes ƒ / Mr. Do outdone.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-12  |  3.7 KB  |  181 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        Mr. Do outdone.c
  4.  
  5. Purpose:    This module handles clearing the screen in a funky
  6.             manner.  See the comments below for more details.
  7.             
  8.  
  9. Sleep Deprivation -- graphic effects on sleep
  10. Copyright (C) 1993 Mark Pilgrim & Dave Blumenthal
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "msg timing.h"
  30.  
  31. #define        BoxSize    2
  32. #define CorrectTime 3
  33.  
  34. void MrDoOutdone(GrafPtr, Pattern*);
  35.  
  36. /* 25 regions on screen, in a 5 x 5 grid.  Regions alternate as to whether they
  37.    scroll up or down. */
  38.    
  39. void MrDoOutdone(GrafPtr thePtr, Pattern *thePattern)
  40. {
  41.     int            x, y;
  42.     int            vgap,hgap;
  43.     Rect        theRect, dest;
  44.     Rect        scrollsource, scrolldest;
  45.     Rect        bounds[25];
  46.     int            width,height;
  47.     
  48.     width=thePtr->portRect.right-thePtr->portRect.left;
  49.     height=thePtr->portRect.bottom-thePtr->portRect.top;
  50.         
  51.     vgap=height/5;
  52.     hgap=width/5;
  53.     
  54.     for (x=0; x<25; x++)
  55.     {
  56.         switch (x)
  57.         {
  58.             case 0:
  59.             case 1:
  60.             case 2:
  61.             case 3:
  62.             case 4:
  63.                 bounds[x].top=0;
  64.                 break;
  65.             case 15:
  66.             case 16:
  67.             case 17:
  68.             case 18:
  69.             case 5:
  70.                 bounds[x].top=vgap;
  71.                 break;
  72.             case 14:
  73.             case 23:
  74.             case 24:
  75.             case 19:
  76.             case 6:
  77.                 bounds[x].top=vgap*2;
  78.                 break;
  79.             case 13:
  80.             case 22:
  81.             case 21:
  82.             case 20:
  83.             case 7:
  84.                 bounds[x].top=vgap*3;
  85.                 break;
  86.             case 12:
  87.             case 11:
  88.             case 10:
  89.             case 9:
  90.             case 8:
  91.                 bounds[x].top=vgap*4;
  92.                 break;
  93.         }
  94.         switch (x)
  95.         {
  96.             case 0:
  97.             case 15:
  98.             case 14:
  99.             case 13:
  100.             case 12:
  101.                 bounds[x].left=0;
  102.                 break;
  103.             case 1:
  104.             case 16:
  105.             case 23:
  106.             case 22:
  107.             case 11:
  108.                 bounds[x].left=hgap;
  109.                 break;
  110.             case 2:
  111.             case 17:
  112.             case 24:
  113.             case 21:
  114.             case 10:
  115.                 bounds[x].left=hgap*2;
  116.                 break;
  117.             case 3:
  118.             case 18:
  119.             case 19:
  120.             case 20:
  121.             case 9:
  122.                 bounds[x].left=hgap*3;
  123.                 break;
  124.             case 4:
  125.             case 5:
  126.             case 6:
  127.             case 7:
  128.             case 8:
  129.                 bounds[x].left=hgap*4;
  130.                 break;
  131.         }
  132.         bounds[x].left+=thePtr->portRect.left;
  133.         bounds[x].top+=thePtr->portRect.top;
  134.         bounds[x].bottom=bounds[x].top+vgap;
  135.         bounds[x].right=bounds[x].left+hgap;
  136.     }
  137.     
  138.     for (x=BoxSize; x<vgap; x+=BoxSize)
  139.     {        
  140.         StartTiming();
  141.         for (y=0; y<25; y++)
  142.         {
  143.             if (y%2)   /* these scroll up */
  144.             {
  145.                 scrollsource=bounds[y];
  146.                 scrollsource.top+=BoxSize;
  147.                 scrolldest=scrollsource;
  148.                 OffsetRect(&scrolldest,0,-BoxSize);
  149.                 
  150.                 dest=bounds[y];
  151.                 dest.top=dest.bottom-BoxSize;
  152.                 
  153.                 CopyBits(&(thePtr->portBits), &(thePtr->portBits),
  154.                         &scrollsource, &scrolldest, 0, 0L);
  155.                 FillRect(&dest, *thePattern);
  156.             }
  157.             else    /* these scroll down */
  158.             {
  159.                 scrollsource=bounds[y];
  160.                 scrollsource.bottom-=BoxSize;
  161.                 scrolldest = scrollsource;
  162.                 OffsetRect(&scrolldest, 0, BoxSize);
  163.                 
  164.                 dest=bounds[y];
  165.                 dest.bottom=dest.top+BoxSize;
  166.                 
  167.                 CopyBits(&(thePtr->portBits), &(thePtr->portBits),
  168.                         &scrollsource, &scrolldest, 0, 0L);
  169.                 FillRect(&dest, *thePattern);
  170.                 
  171.             }
  172.         }
  173.         TimeCorrection(CorrectTime);
  174.     }
  175.     
  176.     SetRect(&dest, thePtr->portRect.left,
  177.         thePtr->portRect.top, thePtr->portRect.right,
  178.         thePtr->portRect.bottom);
  179.     FillRect(&dest, *thePattern);
  180. }
  181.